Skip to content

Fix legend D without offset and G without argument - #9280

Merged
Esteban82 merged 3 commits into
masterfrom
legend-fix-D-G
Oct 28, 2026
Merged

Esteban82 merged 3 commits into
masterfrom
legend-fix-D-G

Conversation

@Esteban82

@Esteban82 Esteban82 commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Two more small bugs in the legend records, found while auditing pslegend.c (follow-up to #9277). Bugs found by Claude Opus 5.5; fix written by Claude Sonnet 5.5.

This was first pushed directly to master by mistake and reverted in f0d9d18; this PR proposes it again.

  1. D 1p + (offset left out): the legend height estimate read it as offset=1p, pen=+, but drawing reads it as pen=1p with flag +. So the automatic height of the box was different from the one for D 0 1p +, which draws exactly the same. The same happens with the flags - and =.
  2. G without argument: it read past the end of the record, printing garbage warnings and exiting with code 0. It now reports Not enough arguments given to G operator.

Scripts to see both:

# 1. Both legends draw the same, so both heights should be the same
printf 'S - c 0.3c red 0.5p - A\nD 1p +\nS - c 0.3c blue 0.5p - B\n' | gmt pslegend -Dx0/0+w5c -Vi 2>&1 >/dev/null | grep estimated
printf 'S - c 0.3c red 0.5p - A\nD 0 1p +\nS - c 0.3c blue 0.5p - B\n' | gmt pslegend -Dx0/0+w5c -Vi 2>&1 >/dev/null | grep estimated

# 2. Expected: a clear error and a non-zero exit code
printf 'S - c 0.3c red 0.5p - A\nG\nS - c 0.3c blue 0.5p - B\n' | gmt pslegend -Dx0/0+w5c > /dev/null; echo "exit code: $?"

In 1, master gives 1.446 cm for D 1p + and 1.330 cm for D 0 1p +; with this PR both are 1.330 cm. In 2, master prints warnings with garbage characters and returns 0; now it prints the error and returns an error code.

🤖 Generated with Claude Code

- D: "D pen flag" (offset left out) was read as offset=pen, pen=flag when
  estimating the legend height, but as pen+flag when drawing, so the
  automatic height differed from "D 0 pen flag". Read it the same way.
- G: a G record without argument read past the end of the record, giving
  garbage warnings and exit code 0. Report a clear error instead.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Esteban82 Esteban82 added the bug Something isn't working label Oct 28, 2026
@Esteban82
Esteban82 requested review from a team, joa-quim and seisman October 28, 2026 11:03
@seisman

seisman commented Oct 28, 2026

Copy link
Copy Markdown
Member

This was first pushed directly to master by mistake and reverted in f0d9d18; this PR proposes it again.

In the AGENTS.md file #9268 we should tell agents to always make changes in a separate branch, not on master

@Esteban82

Copy link
Copy Markdown
Member Author

This was first pushed directly to master by mistake and reverted in f0d9d18; this PR proposes it again.

In the AGENTS.md file #9268 we should tell agents to always make changes in a separate branch, not on master

Yes, I agree. I am not completely sure that it was Claude's fault.

@Esteban82

Copy link
Copy Markdown
Member Author

The ex41 failure is expected. Its legend table has D 1p + and D 1p - (offset left out), exactly the case this PR fixes, so the estimated legend height goes from 13.24 to 12.98 cm and the old baseline no longer matches.

@Esteban82

Copy link
Copy Markdown
Member Author

The +/- bug also affects ex41: the legend frame had extra blank space at the bottom. I will update the ex41 baseline.

bot

@Esteban82
Esteban82 merged commit e67ada7 into master Oct 28, 2026
17 of 20 checks passed
@Esteban82
Esteban82 deleted the legend-fix-D-G branch October 28, 2026 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants